package com.powernode.lambda.lambda;

/**
 * currying柯里化
 */
public class Lambda10 {
    public static void main(String[] args) {
        /**
         * 两个参数的函数对象
         */
        Add add = (a, b)->a+b;
        System.out.println(add.rt(10, 20));

        /**
         * 改造：
         * (a)->返回另一个函数对象
         * (b)->a+b
         */

        Fa fa = a -> b -> a + b;
        Fb fb = fa.rt(10);
        int r = fb.rt(20);
        System.out.println(r);
    }

    @FunctionalInterface
    interface Add{
        int rt(int a, int b);
    }

    @FunctionalInterface
    interface Fa{
        Fb rt(int a);
    }

    @FunctionalInterface
    interface Fb{
        int rt(int a);
    }

}
